#include "head.hpp"
int init_socket(int *socket_fd, const uint16_t port)
{
    *socket_fd = socket(AF_INET, SOCK_STREAM, 0);
    int reuse = 1;
    setsockopt(*socket_fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse));
    struct sockaddr_in local;
    local.sin_family = AF_INET;
    local.sin_port = htons(port);
    local.sin_addr.s_addr = htonl(INADDR_ANY);
    bind(*socket_fd, (struct sockaddr *)&local, sizeof(local));
    listen(*socket_fd, 10);
    return 0;
}